import { ref } from 'vue';
import { add, remove, update } from '@/services';
import { message, Modal } from 'ant-design-vue';

export default function useDeleteConfirm(url, search) {
  const deleteConfirm = id => {
    Modal.confirm({
      title: '确认删除',
      content: '确定要删除这条记录吗？',
      okText: '确认',
      cancelText: '取消',
      onOk: () => doDelete(id),
    });
  };

  const doDelete = async id => {
    await remove(`/api/${url}`, id);
    if (search) await search();
  };
  return {
    deleteConfirm,
  };
}
